<template>
  <div>

  <!-- 暂未审核页 -->
  <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="暂未审核" name="second">
      <div>
      <el-form ref="form" :model="form" label-width="80px">

  <!-- 审核人与审核类型绑定 -->
  <el-form-item label="审核人">
    <el-select v-model="form.approvalName" placeholder="请选择监考老师">

      <!-- 绑定changtype事件 -->
      <!-- A老师 -->
      <el-option label="A老师" value="A老师" :type="form.approvalName == 1 ? 'info' : ''"
        round
        @click="changeType(1)">
      </el-option>

      <!-- B老师 -->
      <el-option label="B老师" value="B老师" :type="form.approvalName == 2 ? 'info' : ''"
                  round
                 @click="changeType(2)">
      </el-option>

      <!-- C老师 -->
      <el-option label="C老师" value="C老师" :type="form.approvalName == 3 ? 'info' : ''"
                 round
                 @click="changeType(3)">
      </el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="审核类型">
    <el-select v-model="form.reviewName" placeholder="请选择审核类型">
      <el-option label="一级审核" value="一级审核"></el-option>
      <el-option label="二级审核" value="二级审核"></el-option>
    </el-select>
  </el-form-item>


  <el-form-item label="审核时间">
    <el-col :span="11">
      <el-date-picker type="date" placeholder="选择日期" v-model="form.approvalTime" style="width: 30%;"></el-date-picker>
    </el-col>
  </el-form-item>


  <el-form-item label="审核结果:">
    <el-radio-group v-model="form.approvalTag">
      <el-radio  label="审核通过" ></el-radio>
      <el-radio  label="审核不通过" ></el-radio>
    </el-radio-group>
  </el-form-item>
  <el-form-item label="审核意见">
    <el-input type="textarea" v-model="form.reviewMessage"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onSubmit()">保存</el-button>
    <el-button>取消</el-button>
  </el-form-item>
</el-form>
    </div>
    </el-tab-pane>



  </el-tabs>

  </div>
</template>
<script>
  export default {
    created() {
      // console.log(this.$route.query.id)
      // let id = this.$route.query.id
      // console.log("id",id)
      // let id = this.form.id
      this.form.id = this.$route.query.id,
        
      console.log(this.form.id);
    },


    data() {
      return {
        activeName: 'second',

        //参数
        form: {
          id: '',
          approvalName:'',
          reviewName: '',
          approvalTime: '',
          approvalTag:'',
          reviewMessage:'',

        },
        //基本信息用
      listData1: [{
        a:'aaa',
        b:'bbb'
      }],

      //试卷信息用
      listData2: [{

      }],



      ruleForm: {
        type: [],
        timeAoe: [],
        dutyAoe: [],
        falutAoe: [],
        origin: "",
        selectNums: "",
        multiNums: "",
        torfNums: "",
        timeCheck: false,
        dutyCheck: false,
        falutCheck: false,
      },

      };
    },
    methods: {
      handleClick(tab, event) {
        console.log(tab, event);
      },

      //存储type
      changeType(num) {
        this.form.type = num;
      },

      //保存按钮
      onSubmit(id) {

        //打印id
        console.log("id",this.form.id)
        // console.log("id2",this.form.id)
        // id = this.form.id
        // console.log(id)
        this.form.approvalTag = this.form.approvalTag=="审核通过"?1:2;
        console.log(this.form)
        //审核保存
        this.$axios.post("http://localhost:8080/reviewAdministration/updateOne/" , this.form)
            .then(res => {
              //打印
              console.log("保存",res)
        })

        this.$router.push('/exam/index')
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert("submit!");
          } else {
            console.log("error submit!!");
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        Object.assign(this.ruleForm, {
          timeAoe: [],
          dutyAoe: [],
          falutAoe: [],
          timeCheck: false,
          dutyCheck: false,
          falutCheck: false,
        });
      },
      selectType() {
        let type = this.ruleForm.type;
        type.includes("时间频率")
            ? (this.ruleForm.timeCheck = true)
            : (this.ruleForm.timeCheck = false);
        type.includes("值班规则")
            ? (this.ruleForm.dutyCheck = true)
            : (this.ruleForm.dutyCheck = false);
        type.includes("故障处理")
            ? (this.ruleForm.falutCheck = true)
            : (this.ruleForm.falutCheck = false);
      },
    },
  };
</script>